<%layout("/eova/layout/default.html",{'title' : 'CRUD'}){%>
<body class="easyui-layout">
<%if(isTrue(isQuery!)){%>
<div id="layoutNorth" region="north" title="快速查询" split="true">
    <#query id="queryForm" items="${itemList}" />
</div>
<%}%>
<div data-options="region:'center',fit:false,border:false,split:false">
    <div id="contentLayout" class="easyui-layout" data-options="fit:true">
        <div data-options="region:'north',fit:false,border:false,split:true" style="height:200px">
            <div id="gridToolbar" style="display: none;">
                <table>
                    <tr>
                        <%if(isQuery){%>
                        <td><%include("/eova/widget/form/btn/query.html",{'formId':'queryForm', 'gridId':'grid'}){}%></td>
                        <%}%>
                        <%// 自定义功能按钮%>
                        <%for(btn in btns){%>
                        <td><%include(btn.ui,{'object':object, 'gridId':'grid'}){}%></td>
                        <%}%>
                    </tr>
                </table>
            </div>
            <#grid id="grid" toolbar="gridToolbar" objectCode="${objectCode}" cellEdit="add,update,delete" />
        </div>
        <div data-options="region:'center'" data-options="fit:true,border:false,split:false">
            <div id="sonTab" class="easyui-tabs" data-options="fit:true,border:false">
                <div title="${slaveObject.name}">
                	<div id="slaveGridToolbar" style="display: none;">
		                <table>
		                    <tr>
                                <%// 子表工具栏%>
                                <%for(btn in btns1){%>
                                <td><%include(btn.ui,{'object':slaveObject, 'gridId':'slaveGrid'}){}%></td>
                                <%}%>
		                    </tr>
		                </table>
		            </div>
                    <#grid id="slaveGrid" masterId="grid" toolbar="slaveGridToolbar" configJson="${configJson!}" objectCode="${slaveObject.code}" isFirstLoad="false" isPaging="false" cellEdit="add,update,delete" />
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){
        $('#grid').datagrid({
            onSelect:function(rowIndex, rowData){
                $('#slaveGrid').datagrid('load',{
                    ${'query_' + config.fields[0]} : rowData.${config.objectField}
                });
            },
            onLoadSuccess: function(data){
                // 初始化选中行
                $(this).datagrid('selectRow', 0);
            }
        });
    });
</script>
<script type="text/javascript" src="/ui/js/template.js"></script>
<%if(!isEmpty(menu.diy_js!)){%>
<script type="text/javascript" src="${menu.diy_js}"></script>
<%}%>
</body>
<%}%>